﻿using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {

            InitializeComponent();
            this.Text = "myForm";
        }

        private void open_btn_Click(object sender, EventArgs e)
        {
            string exe_path = @"D:\lol\lol\TCLS";
            /* if (File.Exists(exe_path))
             {
                 MessageBox.Show("这是一个文件");
             }
             else if (Directory.Exists(exe_path))
             {
                 MessageBox.Show("这是一个文文件夹");
             }
             else
             {
                 MessageBox.Show("{0} 不是文件也不是文件夹.", exe_path);
             }
             if (Directory.Exists(exe_path))//判断是否存在

             {

                 MessageBox.Show("存在");

             }
             else

             {
                 MessageBox.Show("不存在");

             
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.FileName = "Client.exe";
            process.StartInfo.WorkingDirectory = exe_path;
            process.StartInfo.CreateNoWindow = true;
            process.Start();
            }*/
            MyFindWindow();
        }

        [DllImport("User32.dll", EntryPoint = "FindWindow")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        public static void MyFindWindow()
        {
            IntPtr ParenthWnd = new IntPtr(0);
            ParenthWnd = FindWindow(null, "英雄联盟登录程序");
            //判断这个窗体是否有效 
            if (ParenthWnd != IntPtr.Zero)
            {
                MessageBox.Show("找到窗口");
            }

            else
            {
                MessageBox.Show("没有找到窗口");
            }
        }

    }


}
